//
//  HNSH_GoodsSpecItemCell.m
//  HNSH_SingleProject
//
//  Created by 李宇廷 on 2023/2/25.
//

#import "HNSH_GoodsSpecItemCell.h"

@interface HNSH_GoodsSpecItemCell ()
/**  */
@property (nonatomic, strong)UILabel * label;
@end

@implementation HNSH_GoodsSpecItemCell

- (instancetype)initWithFrame:(CGRect)frame {
    self = [super initWithFrame:frame];
    if (self) {
        [self addAllViews];
        [self addAllLayout];
    }
    return self;
}

//MARK: Cycle Methods
- (void)addAllViews{
    [self.contentView addSubview:self.label];
}

- (void)addAllLayout{
    [self.label mas_makeConstraints:^(MASConstraintMaker *make) {
        make.edges.mas_equalTo(self.contentView);
    }];
}

//MARK: Setter Methods
- (void)setTitle:(NSString *)title{
    _title = title;
    
    self.label.text = title;
}

- (void)setIsSelected:(BOOL)isSelected{
    _isSelected = isSelected;
    
    if (isSelected) {
        self.label.backgroundColor = [UIColor colorWithHexString:@"#E5FFD6"];
        self.label.textColor = [UIColor appGreenColor];
    } else {
        self.label.backgroundColor = [UIColor colorWithHexString:@"#F4F4F4"];
        self.label.textColor = [UIColor appBlackLabelColor];
    }
}

//MARK: Getter Methods
- (UILabel *)label{
    if (!_label) {
        _label = [UILabel new];
        _label.backgroundColor = [UIColor colorWithHexString:@"#F4F4F4"];
        _label.textAlignment = NSTextAlignmentCenter;
        _label.font = [UIFont systemFontOfSize:12];
        _label.textColor = [UIColor appBlackLabelColor];
        _label.layer.cornerRadius = 14;
        _label.layer.masksToBounds = YES;
    }
    return _label;
}
@end
